import com.terrapages.wmsc4j.layer.resolution.Resolution;
import com.terrapages.wmsc4j.layer.resolution.ResolutionSet;

import junit.framework.TestCase;


public class ResolutionSetTest extends TestCase {
	public void testTenZoomLevels()
	{
		ResolutionSet resolutions = new ResolutionSet(new Resolution(0.1234),10);
		assertEquals(0.1234, resolutions.getHighestResolution().getValue());
		assertEquals(0.1234, resolutions.elementAt(0).getValue());
	} 
	
	public void testOneZoomLevels()
	{
		ResolutionSet resolutions = new ResolutionSet(new Resolution(0.1234),1);
		assertEquals(0.1234,resolutions.getHighestResolution().getValue());
		assertEquals(0.1234,resolutions.getLowestResolution().getValue());
		assertEquals(0.1234,resolutions.elementAt(0).getValue());
	}
	
	public void testGetZoomLevelOneRes()
	{
		ResolutionSet resolutions = new ResolutionSet(new Resolution(0.1234),1);
		assertEquals(0,resolutions.getIndex(new Resolution(0.1234)));
		assertEquals(0,resolutions.getIndex(new Resolution(0.5)));
		assertEquals(0,resolutions.getIndex(new Resolution(0.0005)));
	}
	
	
	public void testGetZoomLevelTenRes()
	{
		ResolutionSet resolutions = new ResolutionSet(new Resolution(0.1024),10);
		assertEquals(0,resolutions.getIndex(new Resolution(0.2048)));
		assertEquals(0,resolutions.getIndex(new Resolution(0.1024)));
		assertEquals(1,resolutions.getIndex(new Resolution(0.0512)));
		assertEquals(2,resolutions.getIndex(new Resolution(0.0256)));
		assertEquals(7,resolutions.getIndex(new Resolution(0.0008)));
		assertEquals(8,resolutions.getIndex(new Resolution(0.0004)));
		assertEquals(9,resolutions.getIndex(new Resolution(0.0002)));
		assertEquals(9,resolutions.getIndex(new Resolution(0.0001)));
		
		assertEquals(0,resolutions.getIndex(new Resolution(0.0769)));
		assertEquals(1,resolutions.getIndex(new Resolution(0.0768)));
		assertEquals(1,resolutions.getIndex(new Resolution(0.0767)));
	}
}
